package com.deng.common.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.deng.common.SQLHelper;
import com.deng.common.dao.IGangWeiMingCheng;
import com.deng.common.vo.DispenseOrganizationVo;
import com.deng.common.vo.GangWeiMingChengVo;

public class GangWeiMingChengImpl extends SQLHelper implements IGangWeiMingCheng {

	public List<GangWeiMingChengVo> getAllData() {
		try{
			Connection conn = getConnect();
			String sql = "select * from DICT_GangWeiMingCheng order by name";
			ResultSet rs = queryData(conn,sql);
			List<GangWeiMingChengVo> l = new ArrayList<GangWeiMingChengVo>();
			while(rs.next()){
				GangWeiMingChengVo vo = new GangWeiMingChengVo();
				vo.id = rs.getInt("id");
				vo.name = rs.getString("name");
				if(rs.getBigDecimal("point") != null){
					vo.point = rs.getBigDecimal("point").toString();
				}
				l.add(vo);
			}			
			freeConnection(conn);
			return l;
		}catch(Exception ex){
			ex.printStackTrace();
		}
		return null;
	}

	public GangWeiMingChengVo getDataById(int id) {
		try{
			Connection conn = getConnect();
			String sql = "select * from DICT_GangWeiMingCheng where id = "+id;
			ResultSet rs = queryData(conn,sql);
			List<GangWeiMingChengVo> l = new ArrayList<GangWeiMingChengVo>();
			if(rs.next()){
				GangWeiMingChengVo vo = new GangWeiMingChengVo();
				vo.id = rs.getInt("id");
				vo.name = rs.getString("name");
				if(rs.getBigDecimal("point") != null){
					vo.point = rs.getBigDecimal("point").toString();
				}
				freeConnection(conn);
				return vo;
			}			
			freeConnection(conn);
		}catch(Exception ex){
			ex.printStackTrace();
		}
		return null;
	}

}
